"""

"""

#本文路径 /app3/THUDM--ChatGLM-6B/demo.py

from datetime import datetime
from transformers import AutoTokenizer, AutoModel
print(f"before AutoTokenizer.from_pretrained @ {datetime.now()}")
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True,revision="v1.1.0")
print(f"after AutoTokenizer.from_pretrained, before after AutoModel.from_pretrained @ {datetime.now()}")
model = AutoModel.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True).half().cuda()
print(f"after AutoModel.from_pretrained,before model.eval @ {datetime.now()}")
# 模型文件下载 https://cloud.tsinghua.edu.cn/d/674208019e314311ab5c/?p=%2Fchatglm-6b-int4&mode=list
model = model.eval()
print(f"after model.eval, before model.chat 1 @ {datetime.now()}")
response, history = model.chat(tokenizer, "假设你是作家，请写一个小故事", history=[])
print(f"after model.chat 1 , before  model.chat 2 @{datetime.now()}; resp1=【{response}】")
#你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history)
print(f"after model.chat 2 @{datetime.now()}; resp2=【{response}】")
